Skip to content

fix(app-shell): carry default and visibleWhen through the object-field options editor - #7629

Merged
os-sam merged 1 commit into
mainfrom
claude/issue-7540-option-editor-key-loss
Sep 4, 2026
Merged

fix(app-shell): carry default and visibleWhen through the object-field options editor#7629
os-sam merged 1 commit into
mainfrom
claude/issue-7540-option-editor-key-loss

Conversation

@claude

@claude claude Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #7540

Shape 1 only, as scoped by the dispatching PM on the card: the reader keeps the
whole authored option and the writer puts back what it did not display. No
per-option authoring UI was added — see "Deliberately not done".

What changed

One source file: packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.tsx.

The loss started in the reader, which is why a writer-only patch could not
have closed it. readOptions projected every authored option down to exactly
value / label / color, so default and visibleWhen were already gone
before patchOptions ever ran — whatever the writer were taught to carry, it
can only carry what the reader handed it.

All three parts move together, as the card's fence requires:

  • interface Option (module-local) gains a rest slot for the authored
    keys the editor has no control for.
  • readOptions now keeps the whole authored option, parking everything
    outside the three displayed keys on rest. The slot is only attached when
    there is something to carry, so an option with nothing extra produces a row
    byte-identical to what this reader used to produce.
  • patchOptions spreads that carrier's contents back into the written
    document, displayed keys last so they stay authoritative for their own slots.

rest is editor-internal and never becomes a document key: SelectOptionSchema
is strict, so leaking it would 422 every save. The writer therefore emits a
plain document object and never spreads an Option. A test pins the exact key
set for this.

This mirrors readFields in previews/object-fields-io.ts one level up, which
preserves unknown keys on a field definition and strips only the named retired
keys a shipped build actually wrote (RETIRED_FIELD_KEYS). No counterpart
tombstone list for option keys is owed: all five entries in the registry
(indexed, referenceTo, formula, isSystem, sortOrder) are field-level,
and this editor has only ever written the three keys it displays.

The round trip, measured

Not asserted — these are the observed documents from the ablation run below,
same input, same edit ("edit the Label box"), reader reverted vs. repaired.

Input option: { value: 'alpha', label: 'Alpha', color: '#00ff00', default: true, visibleWhen: 'record.tier == 2' }

written document after one Label edit
before (reader reverted) { value: 'alpha', label: 'Alpha II' } — 2 keys
after (this PR) { value: 'alpha', label: 'Alpha II', color: '#00ff00', default: true, visibleWhen: 'record.tier == 2' } — 5 keys

And the key set directly, from the carrier-leak pin:

Object.keys(option).sort()
before [ 'label', 'value' ]
after [ 'default', 'label', 'value' ]

Re-measured on the installed @objectstack/spec 17.2.0, controls lit before any
row was trusted (the card's table, reproduced independently here):

CONTROL clean  { value:'alpha', label:'A' }        ACCEPT  parsed={"label":"A","value":"alpha"}
NEG-CONTROL    { value:'a',     label:'A' }        REJECT  too_small@[value]
default: true                                      ACCEPT  parsed={…,"default":true}
visibleWhen: "x > 1"   (string)                    ACCEPT  parsed={…,"visibleWhen":{"dialect":"cel","source":"x > 1"}}
visibleWhen: {dialect:'cel', source:'x > 1'}       ACCEPT  same envelope
visibleWhen: true      (boolean)                   REJECT  invalid_union@[visibleWhen]
CONTROL unknown key { …, zzz:1 }                   REJECT  unrecognized_keys@[](zzz)
label omitted                                      REJECT  invalid_type@[label]
label: ''                                          ACCEPT  (the #7014 Q2 repair, untouched)

Two traps inherited from the card rather than re-earned: a select option's
value must be at least 2 characters (a 1-character value poisons every row
with too_small@[value] and the visibleWhen rows then say nothing), and the
boolean form of visibleWhen is refused — it is the string form that is
accepted and canonicalized into the expression envelope.

Ablation

Restored the original readOptions projection only, leaving the repaired
writer in place — the sharpest test of the card's central claim that the reader
is the loss site. Predictions written before the run; observed matched
case-for-case, 10 of 10.

Mutation proven on disk before the run: old-projection anchor count 1 (expected
1), carrier-attach anchor count 0 (expected 0), blob
31c5cf3e to b490fcf0. No rebuild leg applies — the test imports
./ObjectFieldInspector, the relative source, not a package dist, so vitest
resolves the mutated file directly. Restore proven: blob back to 31c5cf3e
(equal to HEAD's) and git diff HEAD empty.

case predicted observed
default: true on an untouched row survives RED RED — expected undefined to be true
default: true survives on the row being edited RED RED — …(2) to deeply equal …(3)
written option ACCEPTED by SelectOptionSchema and FieldSchema GREEN GREEN
visibleWhen string form survives verbatim RED RED — expected undefined to be 'record.tier == 2'
visibleWhen envelope form survives verbatim RED RED — expected undefined to deeply equal {dialect:'cel',…}
both keys ride together on one option RED RED — …(2) to deeply equal …(4)
editor-internal carrier never reaches the document RED RED — [ 'label', 'value' ] vs [ 'default', 'label', 'value' ]
the ACCEPTs are not vacuous (pure contract controls) GREEN GREEN
an option with nothing extra is written exactly as before GREEN GREEN
a spec-refused key is carried, not laundered RED RED — expected undefined to be 1
ObjectFieldInspector.optionLabel.test.tsx (#7014 Q2, 5 cases) GREEN GREEN

Totals: Tests 7 failed | 8 passed (15) ablated, 15 passed (15) repaired.

The third row is the one worth reading twice. Dropping both keys still yields
a document the contract ACCEPTS
— which is exactly why this bug was silent
rather than a 422, and why an "is the payload valid?" test can never detect it.
That case is deliberately kept in the suite as a non-detector.

Verification

Every run below is on 7001725f, the tree as pushed, with a clean working tree.
Exit codes captured by redirecting to a file, never through a pipe.

command verdict line
pnpm exec vitest run …/ObjectFieldInspector.optionKeyPreservation.test.tsx …/ObjectFieldInspector.optionLabel.test.tsx Test Files 2 passed (2) · Tests 15 passed (15)
pnpm exec vitest run packages/app-shell/src/views/metadata-admin/ Test Files 226 passed (226) · Tests 2341 passed | 1 skipped (2342)
pnpm exec vitest related --run …/ObjectFieldInspector.tsx Test Files 53 passed (53) · Tests 414 passed (414)
pnpm exec turbo run type-check --concurrency=2 (whole repo) Tasks: 81 successful, 81 total
pnpm exec eslint over both changed files ✖ 12 problems (0 errors, 12 warnings), exit 0
node scripts/check-changeset-presence.mjs ✅ 1 source file(s) of 1 released package(s) changed, and this change declares 1 changeset(s)
pnpm run changeset:check ✅ All workspace packages are in the changeset fixed group. · ✅ No changeset declares a major bump.

Notes on how to read those:

  • The 12 eslint warnings are pre-existing and unchanged, not introduced
    here: : any occurrences in this file are 1 at origin/main and 1 at HEAD
    (the raw.map((o: any) …) the original reader already had). 0 errors.
  • The new test file really is type-checked. The package runs
    tsc --noEmit && tsc -p tsconfig.test.json; --listFiles on that second
    program contains both the new test file and the changed source (count 1 each,
    measured — not inferred from the task going green).

Declared narrowing: the full packages/app-shell/ suite

The suite is 615 test files; the 226-file metadata-admin subset alone took
8m34s on the shared box, so the whole package cannot finish inside this seat's
10-minute foreground ceiling. CI runs it in full regardless. What was run
instead is the complete transitive dependent closure, with the three things
that make a narrowing a measurement rather than a gap:

  1. Population from the tool, not from me. vitest related walked its own
    module graph from the changed file and collected the dependents — 53 test
    files spanning exactly two directories, metadata-admin and
    studio-design. That is vitest's answer to "what can observe this file".
  2. Counts from the tool's output. 53 files / 414 tests for the closure;
    226 files / 2341 tests for the whole containing subtree, run independently
    and green.
  3. Invariance for everything untouched. The diff changes one source file.
    Its three touched symbols — interface Option, readOptions,
    patchOptions — are all module-local (no export; lines 95, 125, 449). The
    file's only export is the ObjectFieldInspector component at line 258, whose
    signature is unchanged, and the whole-repo type-check (81/81) confirms no
    type consumer moved. So no test outside that closure can observe this change.

Repo-wide pnpm lint is likewise CI-owned. Its relevance here is bounded by the
same invariance: eslint.config.js declares no projectService and no
parserOptions.project (type-aware linting is off), so a one-file diff cannot
move the verdict on any file it does not contain.

Housekeeping

Clause-②: no. Re-judged from this diff rather than inherited:

  • Nothing published moves. The only exported symbol in the changed file is
    the ObjectFieldInspector component, and its props type
    (MetadataInspectorProps) is untouched. interface Option carries no
    export modifier — verified on this diff, at line 95 — so the widened type is
    not reachable from any other module, let alone from a published entry point.
  • The accept set does not move. @objectstack/spec is not touched, and both
    keys were already ACCEPTED by SelectOptionSchema 17.2.0 before this PR
    (probe table above). The repair stops the editor dropping keys the
    contract already takes; it does not ask the contract to take anything new.

One behaviour change a reviewer should see plainly rather than discover, since
it is the honest cost of "preserve what the editor does not display": an option
carrying a key the spec refuses is now carried through instead of being
silently dropped, so a save of such a document surfaces
unrecognized_keys@[options[0]] where it previously succeeded by quietly
rewriting the author's document. I judge this correct and in-contract — the
document was already illegal before the inspector opened it (the pin asserts
exactly that, so the case cannot be misread as this PR creating a 422), the
editor declines to hide a pre-existing violation rather than laundering it, and
it is the same contract readFields keeps one level up. It is a behaviour
change, not a contract change: the published accept set is identical. Flagging
it because it is the one place where reasonable people could want the opposite
default; say so and I will switch to an explicit two-key allowlist.

Deliberately not done

🤖 Generated with Claude Code

https://claude.ai/code/session_01KbJQ1y1J12nZxYzFWhP8Q3


Generated by Claude Code

…field options editor (objectui#7540)

Editing any picklist option in the metadata-admin designer wrote the option
back without its `default` or `visibleWhen` key. The payload stayed valid, so
nothing surfaced -- silent data loss of two keys the platform honours, one of
them (`default`) ruled `enforce` on the object-field face.

The loss started in the READER. `readOptions` projected each authored option
to exactly `value` / `label` / `color`, so both keys were gone before
`patchOptions` ever saw them and no writer-only repair could have carried
them. `readOptions` now keeps the whole authored option, parking the keys the
editor has no control for on an internal carrier, and `patchOptions` spreads
that carrier's contents back into the written document.

This mirrors `readFields` one level up, which preserves unknown keys on a
field definition and strips only the named retired keys a shipped build
actually wrote. There is no counterpart tombstone list for option keys and
none is owed: every entry in the registry is field-level, and this editor has
only ever written the three keys it displays.

No authoring UI changed -- per-option controls for these keys are a separate
product question.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KbJQ1y1J12nZxYzFWhP8Q3
@github-actions github-actions Bot added the tests label Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Eager closure (gzip, 50 chunks) 3182.7 KB 3191.4 KB
Main entry chunk (gzip) 143.2 KB 350 KB
Entry file index-Lbe-u4l3.js
Status PASS

The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it.


📦 Bundle Size Report

Package Size Gzipped
app-shell (consoleActionDispatch.js) 0.20KB 0.19KB
app-shell (index.js) 15.67KB 5.75KB
app-shell (runtime-config.js) 20.68KB 7.36KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 10.06KB 3.86KB
auth (ActiveOrganizationStorage.js) 25.05KB 9.16KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 2.07KB 1.00KB
auth (AuthProvider.js) 40.18KB 10.59KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.15KB 5.39KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.65KB 2.22KB
auth (SocialSignInButtons.js) 9.61KB 3.89KB
auth (UserMenu.js) 3.41KB 1.23KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 40.21KB 10.80KB
auth (createAuthenticatedFetch.js) 8.46KB 3.43KB
auth (index.js) 3.19KB 1.44KB
auth (invitation-status.js) 1.22KB 0.70KB
auth (org-roles.js) 6.66KB 2.78KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 5.30KB 1.02KB
auth (useWorkspaceAdminStatus.js) 5.13KB 2.35KB
collaboration (CommentThread.js) 26.08KB 7.56KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 6.49KB 2.64KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.68KB 0.73KB
collaboration (useCollaborationTranslation.js) 6.05KB 2.52KB
collaboration (useCommentSearch.js) 1.98KB 0.88KB
collaboration (useConflictResolution.js) 7.75KB 1.86KB
collaboration (useMentionNotifications.js) 1.81KB 0.68KB
collaboration (usePresence.js) 6.33KB 1.84KB
collaboration (useRealtimeSubscription.js) 7.91KB 2.01KB
components (index.js) 516.24KB 117.84KB
core (index.js) 6.12KB 2.42KB
create-plugin (index.js) 10.08KB 3.26KB
data-objectstack (index.js) 180.00KB 50.20KB
fields (index.js) 242.40KB 61.26KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (builtinAggregateLabels.js) 0.86KB 0.49KB
i18n (currency.js) 1.22KB 0.64KB
i18n (fallbackInterpolation.js) 6.25KB 2.77KB
i18n (i18n.js) 4.28KB 1.75KB
i18n (index.js) 3.65KB 1.47KB
i18n (pickLocalized.js) 7.62KB 3.26KB
i18n (provider.js) 26.89KB 9.04KB
i18n (useDisplayLocale.js) 2.85KB 1.45KB
i18n (useObjectLabel.js) 34.34KB 9.17KB
i18n (useSafeTranslation.js) 5.60KB 2.33KB
layout (index.js) 38.98KB 10.98KB
mobile (MobileProvider.js) 0.92KB 0.49KB
mobile (ResponsiveContainer.js) 0.94KB 0.38KB
mobile (breakpoints.js) 1.51KB 0.70KB
mobile (createOfflineDataSource.js) 5.61KB 1.75KB
mobile (index.js) 1.99KB 0.87KB
mobile (offlineQueue.js) 3.91KB 1.35KB
mobile (pwa.js) 0.97KB 0.49KB
mobile (serviceWorker.js) 1.48KB 0.62KB
mobile (serviceWorkerSource.js) 3.41KB 1.48KB
mobile (useBreakpoint.js) 1.54KB 0.65KB
mobile (useGesture.js) 6.96KB 1.98KB
mobile (useOfflineSync.js) 1.99KB 0.72KB
mobile (usePullToRefresh.js) 2.53KB 0.85KB
mobile (useResponsive.js) 0.72KB 0.42KB
mobile (useSpecGesture.js) 4.32KB 1.64KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 11.71KB 4.29KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 6.24KB 2.16KB
permissions (discardProofCache.js) 1.04KB 0.55KB
permissions (evaluator.js) 5.12KB 1.74KB
permissions (index.js) 0.93KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.53KB
permissions (usePermissions.js) 4.83KB 2.27KB
plugin-ai (index.js) 15.75KB 3.80KB
plugin-calendar (index.js) 48.09KB 13.34KB
plugin-charts (index.js) 70.92KB 19.75KB
plugin-chatbot (index.js) 196.19KB 46.43KB
plugin-dashboard (index.js) 132.86KB 34.68KB
plugin-designer (index.js) 212.86KB 43.19KB
plugin-detail (index.js) 250.59KB 64.06KB
plugin-editor (index.js) 2.46KB 1.10KB
plugin-form (index.js) 132.87KB 32.66KB
plugin-gantt (index.js) 167.40KB 41.05KB
plugin-grid (index.js) 210.75KB 56.95KB
plugin-kanban (index.js) 52.71KB 14.55KB
plugin-list (index.js) 113.28KB 27.59KB
plugin-map (index.js) 20.55KB 6.80KB
plugin-markdown (index.js) 13.72KB 4.69KB
plugin-report (index.js) 43.57KB 11.96KB
plugin-timeline (index.js) 30.84KB 8.85KB
plugin-tree (index.js) 9.38KB 3.22KB
plugin-view (index.js) 85.24KB 20.94KB
providers (DataSourceProvider.js) 0.75KB 0.39KB
providers (MetadataProvider.js) 1.37KB 0.59KB
providers (ThemeProvider.js) 1.90KB 0.85KB
providers (UploadProvider.js) 11.66KB 3.50KB
providers (index.js) 0.45KB 0.23KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.62KB 2.34KB
react (LazyPluginLoader.js) 4.47KB 1.63KB
react (SchemaRenderer.js) 81.07KB 26.86KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 4.63KB 2.18KB
react (schema-input.js) 2.32KB 1.24KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (codegen.js) 5.41KB 2.34KB
sdui-parser (dashboard-widget-options.js) 3.08KB 1.30KB
sdui-parser (index.js) 4.93KB 2.24KB
sdui-parser (input-type.js) 2.84KB 1.40KB
sdui-parser (parse.js) 20.57KB 5.88KB
sdui-parser (provenance.js) 3.66KB 1.82KB
sdui-parser (types.js) 0.28KB 0.23KB
sdui-parser (validate.js) 10.35KB 3.60KB
types (ai.js) 0.20KB 0.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 2.87KB 1.00KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (complex.js) 2.74KB 1.41KB
types (crud.js) 0.20KB 0.18KB
types (dashboard-filter-alias.js) 6.23KB 2.74KB
types (data-display.js) 3.75KB 1.85KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.85KB 0.85KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 0.20KB 0.18KB
types (form.js) 0.20KB 0.18KB
types (http-inflight.js) 8.87KB 3.73KB
types (http-retry.js) 4.32KB 2.02KB
types (icon-key-migration.js) 4.26KB 1.63KB
types (index.js) 4.74KB 2.25KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 4.58KB 2.23KB
types (navigation.js) 0.20KB 0.18KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (permissions.js) 0.20KB 0.18KB
types (plugin-scope.js) 0.20KB 0.18KB
types (record-components.js) 0.20KB 0.19KB
types (record-semantics.js) 1.28KB 0.67KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (select-option.js) 0.20KB 0.19KB
types (spec-report.js) 5.05KB 1.93KB
types (spec-ui-namespace.js) 0.20KB 0.19KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 6.28KB 2.87KB
types (ui-action.js) 8.11KB 3.32KB
types (views.js) 0.20KB 0.18KB
types (widget.js) 0.20KB 0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The object-field options editor silently DROPS default and visibleWhen on every save — and the loss starts in readOptions, not in the writer

2 participants